package ftp;
import it.sauronsoftware.ftp4j.FTPAbortedException;
import it.sauronsoftware.ftp4j.FTPDataTransferException;
import it.sauronsoftware.ftp4j.FTPException;
import it.sauronsoftware.ftp4j.FTPIllegalReplyException;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import main.MusicFile;
import main.MusicType;

import org.junit.Test;


public class FTPTests {

	
	FTPController ftpController = FTPController.getInstance();
	String sendFile = "C:\\Users\\Jan\\Downloads\\uTorrent.exe";
	String sendFileTwo = "C:\\Users\\Jan\\Downloads\\House.S08E16.HDTV.x264-LOL.mp4";
	
	@Test
	public void test() throws IllegalStateException, FileNotFoundException, IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException {
	 final MusicFile testFilest = new  MusicFile(1,null, new File(sendFile),false, MusicType.MP3, sendFile, sendFile);
	 final MusicFile testFiles = new  MusicFile(1,null, new File(sendFileTwo),false, MusicType.MP3, sendFile, sendFile);
	 Thread t = new Thread (new Runnable() {
		
		@Override
		public void run() {
			// TODO Auto-generated method stub
		try {
			ftpController.send(testFilest);
		} catch (IllegalStateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPIllegalReplyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPDataTransferException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPAbortedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		}
	});
	t.start();
	Thread k = new Thread (new Runnable() {
		
		@Override
		public void run() {
			// TODO Auto-generated method stub
		try {
			ftpController.send(testFiles);
		} catch (IllegalStateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPIllegalReplyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPDataTransferException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FTPAbortedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		}
	});
	k.start();
	while(true);
	}
	
	 
}